package cn.tedu.store.controller;

import cn.tedu.store.entity.dto.CodeParamDto;
import cn.tedu.store.service.QrcodeService;
import cn.tedu.store.util.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/qrcode")
public class QrcodeController {

    @Autowired
    QrcodeService qrcodeService;

    /**
     * 生成微信小程序二维码
     *
     * @return
     */
    @PostMapping(value = "create")
    public JsonResult genCode(@RequestBody @Validated CodeParamDto codeParam) {
        return new JsonResult(200, qrcodeService.createQrcode(codeParam));
    }


    //@PostMapping(value = "/getQRCode")
    //public JsonResult getQRCode(@RequestBody Meeting meeting){
    //    String code = QRCodeUtil.getCode(meeting.getMeetingCode());
    //    log.info("二维码输出的内容为{}",code);
    //    return new JsonResult(200,code);
    //}
}
